
# 使用多阶段构建，第一阶段只安装必要的软件
FROM alpine:latest as builder

# 合并更新和安装软件的 RUN 指令，并清理缓存
RUN echo "http://dl-cdn.alpinelinux.org/alpine/latest-stable/community" >>/etc/apk/repositories && \
    sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories && \
    apk update && \
    apk add --no-cache jq docker-cli bash docker-cli-compose yq openssh openssh-server openrc vim && \
    rm -rf /var/cache/apk/*

# 第二阶段从 scratch 开始构建最小镜像
# FROM scratch

# COPY --from=builder / /

RUN ssh-keygen -t rsa -N '' -f /root/.ssh/id_rsa -q

RUN sed -i '/Port /c Port 8922' /etc/ssh/sshd_config && rc-update add sshd

# 设置工作目录
WORKDIR /app

# 复制脚本文件
COPY ./gen-homepage-config.sh /app/gen-homepage-config.sh

# 赋予脚本执行权限
RUN chmod +x /app/gen-homepage-config.sh

# 设置入口点
ENTRYPOINT [ "/app/gen-homepage-config.sh" ]
